<?php

namespace app\common\model\task;

use app\admin\model\Admin;
use think\Model;

class Sign extends Model
{
    // 表名
    protected $name = 'finance_extract_task_sign';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'userid_text',
        'createtime_text'
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        return date('Y-m-d H:i:s',$data['createtime']);
    }

    public function getUseridTextAttr($value, $data)
    {
        $admin = Admin::get(['userid'=>$data['userid']]);
        return $admin['username'];
    }

}
